<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../css/mui.min.css">
		<style>

		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <h1 class="mui-title">开门</h1>
		</header>
		<div id="door-vue" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<ul class="mui-table-view">
					<li v-for="d in devices" class="mui-table-view-cell mui-media">
						<a href="javascript:;">
							<img v-if="d.deviceState == 1" class="mui-media-object mui-pull-left" src="../img/Cloud_Mobile_Device_64px_1098667_easyicon.net.png">
							<img v-if="d.deviceState == 0" class="mui-media-object mui-pull-left" src="../img/Cloud_Mobile_Device_Silver_64px_1098668_easyicon.net.png">
							<div class="mui-media-body">
								{{ d.deviceName }}
								<p class="mui-ellipsis">
									<label class="mui-pull-left">设备编号 {{ d.deviceIdentifier }}</label>
								</p>
							</div>
						</a>
					</li>
				</ul>
			</div>
		</div>

	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/vue.min.js"></script>
	<script>
		var doorVue = new Vue({
			el: "#door-vue",
			data: {
				devices: []
			},
			methods: {
				loadDevices: function(size) {
					if(size == 0) {
						this.devices = [];
					}

					this.devices.push({
						id: "1",
						deviceName: "公司大门",
						deviceIdentifier: "1001",
						deviceState:"0"
					});
					this.devices.push({
						id: "2",
						deviceName: "王经理办公室",
						deviceIdentifier: "1002",
						deviceState:"1"
					});
				}
			}
		})

		mui.init({
			swipeBack: false,
			pullRefresh: {
				container: '#door-vue',
				down: {
					style: 'circle',
					height: 100,
					auto: true,
					contentdown: "下拉可以刷新",
					contentover: "释放立即刷新",
					contentrefresh: "正在刷新...",
					callback: pulldownRefresh
				},
				up: {
					contentrefresh: '正在加载...',
					callback: pullupRefresh
				}
			}
		});

		/**
		 * 下拉刷新具体业务实现
		 */
		function pulldownRefresh() {
			setTimeout(function() {
				doorVue.loadDevices(0);
				mui('#door-vue').pullRefresh().endPulldownToRefresh();
				mui('#door-vue').pullRefresh().endPullupToRefresh((false)); 
			}, 1000);
		}

		function pullupRefresh() {
			setTimeout(function() {
				mui('#door-vue').pullRefresh().endPullupToRefresh((true)); //参数为true代表没有更多数据了。
				doorVue.loadDevices(visitorVue.visitors.length);
			}, 1000);
		}
		
	</script>

</html>